package com.tj.view.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/7/17 0017.
 */

public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getContentViewId());
        //view注入
        ButterKnife.bind(this);

        initView(savedInstanceState);
        initData();
    }

    /**
     * 当前窗的viewId
     *
     * @return
     */
    public abstract int getContentViewId();

    /**
     * 初始化view
     *
     * @param savedInstanceState
     */
    public abstract void initView(Bundle savedInstanceState);

    /**
     * 初始化数据
     */
    public abstract void initData();

    /**
     * @Title: toast
     */
    public void makeToast(String message) {
        Toast.makeText(this.getApplicationContext(), message, Toast.LENGTH_SHORT)
                .show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }


}
